package com.renhuikeji.pro.ala.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ImageSpan;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.google.gson.Gson;
import com.renhuikeji.pro.ala.R;
import com.renhuikeji.pro.ala.activity.LoginActivity;
import com.renhuikeji.pro.ala.bean.GetClickUrlBean;
import com.renhuikeji.pro.ala.bean.GoodsBean;
import com.renhuikeji.pro.ala.bean.HomeRecyBean;
import com.renhuikeji.pro.ala.bean.VisitResultBean;
import com.renhuikeji.pro.ala.config.ConfigValue;
import com.renhuikeji.pro.ala.utils.AliUtils.AliUtils;
import com.renhuikeji.pro.ala.config.Constant;
import com.renhuikeji.pro.ala.utils.OkHttpUtils;
import com.renhuikeji.pro.ala.utils.SPUtils;
import com.renhuikeji.pro.ala.utils.ToastUtils;
import com.renhuikeji.pro.ala.utils.glide.GlideImageLoader;
import com.renhuikeji.pro.ala.views.LabelImageView;

/**
 * Created by Administrator on 2017/4/21.
 * <p>
 * 首页推荐商品展示适配器
 */

public class HomeRecyAdapter extends ListBaseAdapter<GoodsBean.ListBean> {
    GlideImageLoader imageLoader;
    String uid;
    String session;
    private Context context;

    public HomeRecyAdapter(Context context) {
        super(context);
        this.context=context;
        imageLoader = new GlideImageLoader(context);
        uid = (String) SPUtils.get(context, Constant.User_Uid, "");
        session = (String) SPUtils.get(context, Constant.MSESSION, "");
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_goods;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        final GoodsBean.ListBean bean = mDataList.get(position);
        LinearLayout llGoodsItem = holder.getView(R.id.ll_goods_item);

        ImageView imageView = holder.getView(R.id.imageview); //图片
        TextView text_quan = holder.getView(R.id.text_quan); //领券省5元
        TextView tvCoupon = holder.getView(R.id.tv_coupon); //领券省5元
        tvCoupon.setText("优惠券\n"+bean.getCoupon_price()+"元");
        TextView tv_goodIntroduce = holder.getView(R.id.tv_goodIntroduce); //商品介绍
        tv_goodIntroduce.setText(bean.getGoods_title());
        TextView tv_nowPrice = holder.getView(R.id.tv_nowprice);  //现价
        tv_nowPrice.setPaintFlags(tv_nowPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        TextView tv_PriceAfter = holder.getView(R.id.tv_price_after);  //
        tv_PriceAfter.setText("￥" + bean.getGoods_price());
        imageLoader.display(imageView, bean.getGoods_pic(), R.mipmap.icon_wanlibao_grey);

//            text_quan.setText("领券省\r\n" + bean.quan_num + "元");

        if (TextUtils.isEmpty(bean.getGoods_price())) {
            tv_nowPrice.setText("");
        } else {
            tv_nowPrice.setText("￥" + bean.getGoods_price());
        }
    }
}
